package com.houweishi.module.outbound.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.outbound.domain.BizOutboundProduct;
import com.houweishi.module.outbound.service.IBizOutboundProductService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 出库产品Controller
 * 
 * @author houweishi
 * @date 2023-02-25
 */
@RestController
@RequestMapping("/module/outboundproduct")
public class BizOutboundProductController extends BaseController
{
    @Autowired
    private IBizOutboundProductService bizOutboundProductService;

    /**
     * 查询出库产品列表
     */
    @PreAuthorize("@ss.hasPermi('module:outboundproduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizOutboundProduct bizOutboundProduct)
    {
        startPage();
        List<BizOutboundProduct> list = bizOutboundProductService.selectBizOutboundProductList(bizOutboundProduct);
        return getDataTable(list);
    }

    /**
     * 导出出库产品列表
     */
    @PreAuthorize("@ss.hasPermi('module:outboundproduct:export')")
    @Log(title = "出库产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizOutboundProduct bizOutboundProduct)
    {
        List<BizOutboundProduct> list = bizOutboundProductService.selectBizOutboundProductList(bizOutboundProduct);
        ExcelUtil<BizOutboundProduct> util = new ExcelUtil<BizOutboundProduct>(BizOutboundProduct.class);
        util.exportExcel(response, list, "出库产品数据");
    }

    /**
     * 获取出库产品详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:outboundproduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizOutboundProductService.selectBizOutboundProductById(id));
    }

    /**
     * 新增出库产品
     */
    @PreAuthorize("@ss.hasPermi('module:outboundproduct:add')")
    @Log(title = "出库产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizOutboundProduct bizOutboundProduct)
    {
        return toAjax(bizOutboundProductService.insertBizOutboundProduct(bizOutboundProduct));
    }

    /**
     * 修改出库产品
     */
    @PreAuthorize("@ss.hasPermi('module:outboundproduct:edit')")
    @Log(title = "出库产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizOutboundProduct bizOutboundProduct)
    {
        return toAjax(bizOutboundProductService.updateBizOutboundProduct(bizOutboundProduct));
    }

    /**
     * 删除出库产品
     */
    @PreAuthorize("@ss.hasPermi('module:outboundproduct:remove')")
    @Log(title = "出库产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizOutboundProductService.deleteBizOutboundProductByIds(ids));
    }
}
